<?php
namespace app\m\controller;
class Article extends Base{

    //文章分类
    public function cat(){
        //文章
        $article_cat1 = $this->db->query('select * from article_cat where parent_id = ? order by sort asc',[1]);
        $this->fetch(['article_cat1'=>$article_cat1]);
    }


    //文章列表
    public function lists(){
        $cat_id = $this->get('cat_id');
        $cat_detail = $this->db->find('article_cat',$cat_id);
        $list = $this->db->query('select * from article where cat_id = ? and status = 0 order by sort desc',[$cat_id]);
        $this->fetch(['cat_detail'=>$cat_detail,'list'=>$list]);
    }


    //文章详情
    public function detail(){
        $id = $this->get('id');
        //查询文章
        $article_detail = $this->db->find('article',$id);
        $this->fetch(['article_detail'=>$article_detail]);
    }

}
?>
